//
//  NutritionAndNurseViewController.m
//  WE
//
//  Created by 要帅气的生活 on 15/11/25.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "NutritionAndNurseViewController.h"
#import "Size.h"
#import "RegulateOptionsCell.h"
#import "ToningSolutionsCell.h"
#import "UsualDisaViewController.h"
@interface NutritionAndNurseViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *options;//选项
@property (nonatomic,strong) UITableView *content;//内容
@property (nonatomic,strong) NSMutableArray *optionsArray;
@end

@implementation NutritionAndNurseViewController
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"营养调理";
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:255.0/255.0f green:255.0/255.0f blue:255.0/255.0f alpha:1];
    
    self.optionsArray = @[@"所有营养",@"女人魅力",@"男女性福",@"肠胃调理",@"塑身美肤",@"养心护脑",@"骨骼健康",@"护眼明目",@"补肾强身",@"清咽润肺",@"分泌调节",@"神经调节",@"妇幼保健",@"购物车"].mutableCopy;
    [self table];
}

-(void)table{
    
    //UIView *setting = [[UIView alloc] initWithFrame:CGRectMake(WindowWidth/3, 64, WindowWidth, WindowHeight-64)];
    //[self.view addSubview:setting];
    //setting.backgroundColor = [UIColor purpleColor];
    
    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, -35, WindowWidth, WindowHeight+35)];
    [self.view addSubview:scroll];
    //内容视图大小
    scroll.contentSize = CGSizeMake(WindowWidth, 0);
    //滚动  默认YES
    scroll.scrollEnabled = NO;

    scroll.showsHorizontalScrollIndicator = NO;
    
    
    _options = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth/3, WindowHeight+7) style:UITableViewStyleGrouped];
    [scroll addSubview:_options];
    //_options.backgroundColor = [UIColor redColor];
    _options.delegate = self;
    _options.dataSource = self;
    _options.tag = 355;
    _options.rowHeight = 60;
    
    _content = [[UITableView alloc] initWithFrame:CGRectMake(WindowWidth/3, 0, WindowWidth/3*2, WindowHeight+7) style:UITableViewStyleGrouped];
    [scroll addSubview:_content];
    //_content.backgroundColor = [UIColor yellowColor];
    _content.delegate = self;
    _content.showsVerticalScrollIndicator = NO;

    _content.dataSource = self;
    _content.tag = 356;
    _content.rowHeight = 210;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag == 355) {
        return self.optionsArray.count;
    }else if (tableView.tag == 356){
        return 5;
    }else{
        return 0;
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 355) {
        RegulateOptionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"regulate"];
        if (cell == nil) {
            cell = [[RegulateOptionsCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"regulate"];
            
        }
        cell.label.text = _optionsArray[indexPath.row];
        return cell;
    }else{
        ToningSolutionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"toning"];
        if (cell == nil) {
            cell = [[ToningSolutionsCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"toning"];
        }
        cell.name.text = @"橄榄提取物";
        cell.img.image = [UIImage imageNamed:@"shouye5.png"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 356) {
        UsualDisaViewController *usal = [UsualDisaViewController new];
        usal.view.backgroundColor = [UIColor whiteColor];
        [self.navigationController pushViewController:usal animated:YES];
    }
}
@end
